package us.mifeng.basicvp.viewmodel

import us.mifeng.basicvp.base.BaseViewModel
import us.mifeng.basicvp.model.LoginResult
import us.mifeng.basicvp.network.RetrofitClient
import us.mifeng.basicvp.network.api.UserApi

class MainViewModel : BaseViewModel(){
    private val userApi = RetrofitClient.create(UserApi::class.java)



    fun requestMainData(callback: (LoginResult) -> Unit) {
        handleResponse(
           userApi.getUserInfo(),
            onSuccess = { result ->
                // 处理成功的结果
                println("Login successful: ${result.token}")
            },
            onError = { error ->
                // 处理错误
                println("Login failed: ${error.message}")
            }
        )
    }
}